package cmpp.netty;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import io.netty.channel.ChannelHandlerContext;

public class ChannelHandlerContextMap {
	private static Map<String, ChannelHandlerContext> map = new ConcurrentHashMap<String, ChannelHandlerContext>();

	public static void add(String clientId, ChannelHandlerContext channelHandlerContext) {
		map.put(clientId, channelHandlerContext);
	}

	public static ChannelHandlerContext get(String clientId) {
		return map.get(clientId);
	}

	public static void remove(ChannelHandlerContext channelHandlerContext) {
		for (Map.Entry entry : map.entrySet()) {
			if (entry.getValue() == channelHandlerContext) {
				map.remove(entry.getKey());
			}
		}
	}

}